package koala.kuangjiademo.net;


import android.content.Context;
import android.support.v4.widget.SwipeRefreshLayout;

import koala.kuangjiademo.util.Helper;


public class SwipeRefreshLayoutProgressStyle extends BooleanProgressStyle {
    private SwipeRefreshLayout refreshLayout;
    private Context context;

    public SwipeRefreshLayoutProgressStyle(SwipeRefreshLayout refreshLayout) {
        this.refreshLayout = refreshLayout;
        context = refreshLayout.getContext();
    }

    @Override
    public void onProgress(boolean progress) {
        if (refreshLayout.isRefreshing()) {
            if (!progress) refreshLayout.setRefreshing(false);
        } else {
            if (progress) {
                Helper.showProgressDialog(context);
            } else {
                Helper.dismissProgressDialog(context);
            }
        }
    }
}
